package com.zjz.studynotes;

import androidx.room.TypeConverter;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.List;

/**
 * @author: ZJZ
 * @date: 2025/5/7
 * @description：
 */
public class ListStringConverter {
    private Gson gson = new Gson();

    @TypeConverter
    public String fromList(List<String> list) {
        return gson.toJson(list);
    }

    @TypeConverter
    public List<String> toList(String json) {
        Type type = new TypeToken<List<String>>() {}.getType();
        return gson.fromJson(json, type);
    }
}
